#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <unistd.h>
#define SIZE 1024
int lastcode = 0;
char command[SIZE];
char* argv[SIZE]; 
const char* userame()
{
  const char* name = getenv("USER");
  if(name) return name;
  else     return "none";
}
const char* userhome()
{
  const char* home = getenv("HOSTNAME");
  if(home) return home;
  else     return "none";
}
const char* userpwd()
{
  const char* pwd = getenv("PWD");
  if(pwd) return pwd;
  else    return "none";
}

void  Setprint()
{   
   printf("[%s@%s %s]$ ",userame(),userhome(),userpwd());
   fgets(command,SIZE,stdin);
   command[strlen(command)-1] = '\0';
   if(command == "\n" ) printf("\n");
}
void strspilt()
{ 
  int i = 0;
  argv[i] = strtok(command," ");
  while(argv[i])
  {
    argv[i+1] = strtok(NULL," ");
    i++;
  }
}
void Resovlegap()
{
   if(strcmp(argv[0],"export") == 0)  
   {
     if(strcmp(argv[1],"PATH"))
     execvp(argv[0],argv);  
   }
   else if (strcmp(argv[0],"cd")==0)
   {
     char newarr[SIZE];
     snprintf(newarr,"PATH=%s",argv[1]);
     putenv(newarr);
   }
   
}
void Contact()
{
   pid_t pid = fork();
   if(pid == 0)
   {
      execvp("argv[i]",argv);
   }
   int status = 0;
   waitpid(pid,&status,0);
   lastcode = WEXITSTATUS(status); 
}
int main()
{
  Setprint();
  printf("\n%s\n",command);
  return 0;
}
